package mvp.com.bbc.rcjavaretrofitdaggermvp.mvp.adapter;

import android.content.Context;
import android.support.v7.widget.CardView;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.bumptech.glide.Glide;

import java.util.ArrayList;
import java.util.List;

import butterknife.BindView;
import butterknife.ButterKnife;
import mvp.com.bbc.rcjavaretrofitdaggermvp.R;
import mvp.com.bbc.rcjavaretrofitdaggermvp.bean.CommunityListBean;

/**
 * Created by ${cbf} on 2017/12/3.
 */

public class HotMomAdapter extends RecyclerView.Adapter<HotMomAdapter.Vholder> {
    private List<CommunityListBean.ArtBean> artBeen;
    private Context context;
    private String type;

    public HotMomAdapter(Context context, String type) {
        this.context = context;
        this.type = type;
        this.artBeen = new ArrayList<>();
    }

    public void setData(List<CommunityListBean.ArtBean> art) {
        this.artBeen = art;
        notifyDataSetChanged();
    }

    public void addData(List<CommunityListBean.ArtBean> art) {
        this.artBeen.addAll(art);
        notifyDataSetChanged();
    }

    @Override
    public Vholder onCreateViewHolder(ViewGroup parent, int viewType) {
        View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.item_fragment_communtiy, parent, false);
        return new Vholder(view);
    }

    @Override
    public void onBindViewHolder(Vholder holder, int position) {
        CommunityListBean.ArtBean artBean = artBeen.get(position);
        Glide.with(context).load(artBean.getIcon()).into(holder.ivHeaderCircle);
        holder.tvCommentName.setText(artBean.getNicename());
        holder.tvCommentTime.setText(artBean.getCreattime().getTime());
        holder.tvCommentTitle.setText(artBean.getContent());
        holder.tvFocusCommuntiy.setText("关注");
        holder.tvWomanBeautify.setText(artBean.getName());
        holder.tvDianzan.setText(artBean.getLn());
        holder.tvPinlun.setText(artBean.getAc());
    }

    @Override
    public int getItemCount() {
        return artBeen.size();
    }

    public class Vholder extends RecyclerView.ViewHolder {

        private ImageView ivHeaderCircle;
        private TextView tvCommentName,tvCommentTime,tvCommentTitle,tvFocusCommuntiy,tvWomanBeautify,tvDianzan,tvPinlun;
        Vholder(View view) {
            super(view);
            ivHeaderCircle = (ImageView) view.findViewById(R.id.iv_header_circle);
            tvCommentTitle = (TextView) view.findViewById(R.id.tv_comment_title);
            tvCommentName = (TextView) view.findViewById(R.id.tv_comment_name);
            tvCommentTime = (TextView) view.findViewById(R.id.tv_comment_time);
            tvFocusCommuntiy = (TextView) view.findViewById(R.id.tv_focus_communtiy);
            tvWomanBeautify = (TextView) view.findViewById(R.id.tv_woman_beautify);
            tvDianzan = (TextView) view.findViewById(R.id.tv_dianzan);
            tvPinlun = (TextView) view.findViewById(R.id.tv_pinlun);
        }
    }
}
